package holdobject;

import java.util.LinkedList;
public class Stack<T> {
    private LinkedList<T> storage=new LinkedList<T>();
    public void push(T v){storage.addFirst(v);}
    public T peek(){return (T) storage.getFirst();}
    public T pop(){
        return (T)storage.removeFirst();
    }
    public boolean empty(){
        return storage.isEmpty();
    }
    public String toString(){
        return storage.toString();
    }

    public static void main(String[] args) {
        Stack<String> stack=new Stack<String>();
        for (String s:"My dog has fleas".split(" "))//按指定的 分割 字符或字符串
            stack.push(s);//内容，并存放到字符串数组当中
        while (!stack.empty())//执行里面一定是FALSE
            System.out.print(stack.pop()+" ");

    }
}
